import threading


class Task(threading.Thread):

    # 初始化
    def __init__(self, a):
        threading.Thread.__init__(self)
        self.b = a
        # 线程退出标识
        self.exit = threading.Event()

    def run(self):
        print(self.b)

    def stop(self):
        self.exit.set()


task = Task(1)
# 守护线程
task.setDaemon(True)
# 启动
task.start()
